package com.hhx.test_library.api;

import com.hhx.baselibrary.api.RetrofitManager;

/**
 * Created by Administrator on 2019/2/22.
 */

public class ApiManager {

    public static final String BASE_URL = "https://api.haominglijia.com/";

    private static ApiManager apiManager;
    private volatile static TestService testService;

    public static ApiManager getInstance() {
        if (apiManager == null) {
            synchronized (ApiManager.class) {
                if (apiManager == null) {
                    apiManager = new ApiManager();
                }
            }
        }
        return apiManager;
    }

    private <T> T create(final Class<T> service) {
        if (service == null) {
            throw new RuntimeException("Api service is null!");
        }
        return RetrofitManager.getInstance().getSSLRetrofit(BASE_URL).create(service);
    }

    public TestService getTestService() {
        testService = create(TestService.class);
        return testService;
    }
}
